import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import common from './modules/common'
import user from './modules/user'
import menu from './modules/menu'
import loading from './modules/loading'

import createPersistedState from 'vuex-persistedstate'

Vue.use(Vuex)

export default new Vuex.Store({
  plugins: [createPersistedState()],
  state: {
    checktaskInfo: {},
        // 选择渠道
        channel:{},
  },
  modules: {
    common,
    menu,
    user,
    loading
  },
  mutations: {
    // 重置vuex本地储存状态
    resetStore (state) {
      Object.keys(state).forEach((key) => {
        state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
      })
    },
    updatechecktask (state, tabs) {
      state.checktaskInfo = tabs
      // console.log(state, tabs);
    },
    checkChanel (state, tabs) {
      state.channel = tabs
      // sessionStorage.setItem('channel',JSON.stringify(tabs));
      // console.log(state, tabs);
    },
  },
  strict: process.env.NODE_ENV !== 'production'
})
